<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload = function(){
				//创建节点
				var newUl = document.createElement("ul");
				var newLi = document.createElement("li");
				var newLi2 = document.createElement("li");
				var newLi3 = document.createElement("li");
				newUl.appendChild(newLi);
				newUl.appendChild(newLi2);
				newUl.appendChild(newLi3);
				div1.appendChild(newUl);
				
				//添加值
				var newText = document.createTextNode("苹果");
				var newText2 = document.createTextNode("香蕉");
				var newText3 = document.createTextNode("芒果");
				newLi.appendChild(newText);
				newLi2.appendChild(newText2);
				newLi3.appendChild(newText3);
				console.log(newLi);
				
				//为li添加点击事件
				var liNode = document.getElementsByTagName("li");
				for (var i=0;i<liNode.length;i++) {
					liNode[i].onclick = function(){
						alert(this.firstChild.nodeValue);
					}
				}
				
			}
		</script>
	</head>
	<body>
		<div id="div1">
			
		</div>
	</body>
</html>
